/*
** my_ls.c for my_ls in /home/chassa_m/rendu/PSU_2013_my_ls
** 
** Made by chassa_m
** Login   <chassa_m@epitech.net>
** 
** Started on  Mon Nov 25 14:34:54 2013 chassa_m
** Last update Fri Nov 29 11:18:07 2013 chassa_m
*/

#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "list.h"

void	my_ls(char *path)
{
  DIR		*diropen;
  struct dirent	*dirread;
  t_list	**list;

  diropen = opendir(path);
  dirread = readdir(diropen);
  list = malloc(sizeof(*list));
  my_put_in_list(list, dirread->d_name);
  while ((dirread = readdir(diropen)) != NULL)
    my_put_in_list(list, dirread->d_name);
  my_show_list(*list);
  my_putstr("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
  closedir(diropen);
}

int	main(int ac, char **av)
{
  if (av[1])
    my_ls(av[1]);
  else
    my_ls(".");
  return (0);
}
